package com.all.play.myapplication.presenter;

import com.all.play.myapplication.bean.MainModelBean;
import com.all.play.myapplication.model.MainModel;
import com.all.play.myapplication.view.MainView;

/**
 * Created by 聪明一只哈 on 2018/5/16.
 * Time: 2018/5/16  8:49
 *  View和Model的桥梁，它从Model层检索数据后，返回给View层
 */

public class MainPresenter implements Presenter<MainView>,IMainPresenter{

    private MainView mMainView;
    private MainModel mMainModel;

    public MainPresenter(MainView mMainView) {
        attachView(mMainView);
        mMainModel=new MainModel(this);
    }

    @Override
    public void attachView(MainView view) {
        this.mMainView=view;
    }

    @Override
    public void dittachView() {
        this.mMainView=null;

    }

    public void loadData(){
        mMainView.showProgress();
        mMainModel.loadData();
    }

    @Override
    public void loadDataSuccess(MainModelBean mainModelBean) {
        mMainView.show(mainModelBean);
        mMainView.hideProgress();
    }

    @Override
    public void loadDateFailure() {
        mMainView.hideProgress();
    }
}
